package com.yzt.plugin_network.response;

import com.yzt.plugin_network.excep.HttpStatus;

import rx.functions.Func1;

/**
 * author : bob
 * date   : 2022/11/29
 * desc   :
 */
public class HttpResponsePre<T> implements Func1<HttpResponse<T>, T> {

    @Override
    public T call(HttpResponse<T> httpResponse) {
        if (httpResponse.code != HttpStatus.ResponseStatus.STATUS_SUCCESS) {
            throw new AresException(httpResponse);
        }
        return httpResponse.data;
    }
}